﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.BidSystem.Model;

public partial class Share_CompanyNavigation : System.Web.UI.UserControl
{
    private static readonly string formatstring = "<li class=\"{0}\"><a href=\"{1}\">{2}</a></li>";
    protected void Page_Load(object sender, EventArgs e)
    {
        string formatstring1 = "<li class=\"{0}\"><a id=\"addJudge\" href=\"{1}\">{2}</a></li>";
        switch (BidType)
        {
            case BidType.Bargain:
                ltlbidlink.Text = string.Format(formatstring, GetActiveString(ltlbidlink, ActiveLink), "BargainPrice.aspx?action=bargain", "议价报价");
                //ltlConfirmBid.Text = string.Format(formatstring, GetActiveString(ltlConfirmBid, ActiveLink), "ConfirmBid.aspx?action=bargain", "确认议价");
                // ltlPrintBid.Text = string.Format(formatstring, GetActiveString(ltlPrintBid, ActiveLink), "PrePrintPrice.aspx?action=bargain", "打印议价");
                //  ltlDec.Text = string.Format(formatstring, GetActiveString(ltlDec, ActiveLink), "Wait.aspx?action=bargain", "议价解密");
                ltlConfirmBid.Visible = false;
                ltlPrintBid.Visible = false;
                ltlDec.Visible = false;

                break;
            case BidType.Compete:
                ltlbidlink.Text = string.Format(formatstring, GetActiveString(ltlbidlink, ActiveLink), "CompetePrice.aspx?action=compete", "竞价报价");
                ltlConfirmBid.Text = string.Format(formatstring, GetActiveString(ltlConfirmBid, ActiveLink), "ConfirmBid.aspx?action=compete", "确认竞价");
                ltlPrintBid.Text = string.Format(formatstring, GetActiveString(ltlPrintBid, ActiveLink), "PrePrintPrice.aspx?action=compete", "打印竞价");
                ltlDec.Text = string.Format(formatstring, GetActiveString(ltlDec, ActiveLink), "Wait.aspx?action=compete", "竞价解密");
                break;
            default:
                ltlbidlink.Text = string.Format(formatstring, GetActiveString(ltlbidlink, ActiveLink), "BidPrice.aspx?action=bid", "投标报价");
                ltlConfirmBid.Text = string.Format(formatstring, GetActiveString(ltlConfirmBid, ActiveLink), "ConfirmBid.aspx?action=bid", "确认报价");
                ltlPrintBid.Text = string.Format(formatstring, GetActiveString(ltlPrintBid, ActiveLink), "PrePrintPrice.aspx?action=bid", "打印报价");

                if (!CurrentAccount.IsConfirmBid)
                {
                    formatstring1 = "<li onclick=\"toJudgeStatus();\" class=\"{0}\"><a>{2}</a></li>";
                }
                ltlDec.Text = string.Format(formatstring1, GetActiveString(ltlDec, ActiveLink), "Wait.aspx?action=bid", "报价解密");
                break;
        }

    }

    private string GetActiveString(Literal ltl, ActiveLink activelike)
    {
        if (ltl.ID == "ltlbidlink" && activelike == ActiveLink.BidLink)
            return "inactive";
        if (ltl.ID == "ltlConfirmBid" && activelike == ActiveLink.ConfirmLink)
            return "inactive";
        if (ltl.ID == "ltlPrintBid" && activelike == ActiveLink.PrintLink)
            return "inactive";
        if (ltl.ID == "ltlDec" && activelike == ActiveLink.DecLink)
            return "inactive";
        return "unactive";
    }

    /// <summary>
    /// 获取报价类型
    /// </summary>
    public BidType BidType { get; set; }

    /// <summary>
    /// 当前活动的链接
    /// </summary>
    public ActiveLink ActiveLink { get; set; }

}
